home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / chalk.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2005-06-30  |  4.2 KB  |  120 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; This program is free software; you can redistribute it and/or modify
  4. ; it under the terms of the GNU General Public License as published by
  5. ; the Free Software Foundation; either version 2 of the License, or
  6. ; (at your option) any later version.
  7. ; This program is distributed in the hope that it will be useful,
  8. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10. ; GNU General Public License for more details.
  11. ; You should have received a copy of the GNU General Public License
  12. ; along with this program; if not, write to the Free Software
  13. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. ;
  15. ; chalk.scm  version 0.11  10/10/97
  16. ;
  17. ; Copyright (C) 1997 Manish Singh <msingh@uclink4.berkeley.edu>
  18. ;  
  19. ; Makes a logo with a chalk-like text effect.
  20.  
  21. (define (apply-chalk-logo-effect img
  22.                  logo-layer
  23.                  bg-color)
  24.   (let* ((width (car (gimp-drawable-width logo-layer)))
  25.      (height (car (gimp-drawable-height logo-layer)))
  26.      (bg-layer (car (gimp-layer-new img
  27.                     width height RGB-IMAGE
  28.                     "Background" 100 NORMAL-MODE))))
  29.  
  30.     (gimp-context-push)
  31.  
  32.     (gimp-selection-none img)
  33.     (script-fu-util-image-resize-from-layer img logo-layer)
  34.     (gimp-image-add-layer img bg-layer 1)
  35.     (gimp-context-set-background bg-color)
  36.     (gimp-edit-fill bg-layer BACKGROUND-FILL)
  37.  
  38.     ; the actual effect
  39.     (gimp-layer-set-preserve-trans logo-layer FALSE)
  40.     (plug-in-gauss-rle 1 img logo-layer 2.0 1 1)
  41.     (plug-in-spread 1 img logo-layer 5.0 5.0)
  42.     (plug-in-ripple 1 img logo-layer 27 2 0 0 0 TRUE TRUE)
  43.     (plug-in-ripple 1 img logo-layer 27 2 1 0 0 TRUE TRUE)
  44.     (plug-in-sobel 1 img logo-layer TRUE TRUE TRUE)
  45.     (gimp-levels logo-layer 0 0 120 3.5 0 255)
  46.  
  47.     ; work-around for sobel edge detect screw-up (why does this happen?)
  48.     ; the top line of the image has some garbage instead of the bgcolor
  49.     (gimp-rect-select img 0 0 width 1 CHANNEL-OP-ADD FALSE 0)
  50.     (gimp-edit-clear logo-layer)
  51.     (gimp-selection-none img)
  52.  
  53.     (gimp-context-pop)))
  54.  
  55.  
  56. (define (script-fu-chalk-logo-alpha img
  57.                     logo-layer
  58.                     bg-color)
  59.   (begin
  60.     (gimp-image-undo-group-start img)
  61.     (apply-chalk-logo-effect img logo-layer bg-color)
  62.     (gimp-image-undo-group-end img)
  63.     (gimp-displays-flush)))
  64.  
  65. (script-fu-register "script-fu-chalk-logo-alpha"
  66.                     _"_Chalk..."
  67.                     "Chalk scribbled logos"
  68.                     "Manish Singh <msingh@uclink4.berkeley.edu>"
  69.                     "Manish Singh"
  70.                     "October 1997"
  71.                     "RGBA"
  72.                     SF-IMAGE     "Image"            0
  73.                     SF-DRAWABLE  "Drawable"         0
  74.                     SF-COLOR    _"Background color" '(0 0 0))
  75.  
  76. (script-fu-menu-register "script-fu-chalk-logo-alpha"
  77.              _"<Image>/Script-Fu/Alpha to Logo")
  78.  
  79.  
  80. (define (script-fu-chalk-logo text
  81.                   size
  82.                   font
  83.                   bg-color
  84.                   chalk-color)
  85.   (let* ((img (car (gimp-image-new 256 256 RGB)))
  86.      (border (/ size 4))
  87.      (text-layer (car (gimp-text-fontname img -1 0 0 text border TRUE size PIXELS font))))
  88.  
  89.     (gimp-context-push)
  90.  
  91.     (gimp-image-undo-disable img)
  92.     (gimp-drawable-set-name text-layer text)
  93.     (gimp-context-set-foreground chalk-color)
  94.     (gimp-layer-set-preserve-trans text-layer TRUE)
  95.     (gimp-edit-fill text-layer FOREGROUND-FILL)
  96.     (apply-chalk-logo-effect img text-layer bg-color)
  97.     (gimp-image-undo-enable img)
  98.     (gimp-display-new img)
  99.  
  100.     (gimp-context-pop)))
  101.  
  102. (script-fu-register "script-fu-chalk-logo"
  103.                     _"_Chalk..."
  104.                     "Chalk scribbled logos"
  105.                     "Manish Singh <msingh@uclink4.berkeley.edu>"
  106.                     "Manish Singh"
  107.                     "October 1997"
  108.                     ""
  109.                     SF-STRING     _"Text"               "CHALK"
  110.                     SF-ADJUSTMENT _"Font size (pixels)" '(150 2 1000 1 10 0 1)
  111.                     SF-FONT       _"Font"               "Cooper"
  112.                     SF-COLOR      _"Background color"   '(0 0 0)
  113.                     SF-COLOR      _"Chalk color"        '(255 255 255))
  114.  
  115. (script-fu-menu-register "script-fu-chalk-logo"
  116.              _"<Toolbox>/Xtns/Script-Fu/Logos")
  117.